package com.etone.smartAudit.service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.etone.smartAudit.domain.Admin;
import com.etone.smartAudit.domain.EmailRecord;
import com.etone.smartAudit.mapper.EmailRecordMapper;
import com.etone.smartAudit.vo.PagerVO;
import com.etone.smartAudit.vo.email.EmailRecordVO;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * @author: sovy
 * @date: 2020/10/9
 * @description:
 */

@Service
public class EmailRecordService extends ServiceImpl<EmailRecordMapper, EmailRecord> {

    /**
     * 邮件发送记录
     *
     * @param admin
     * @param subject
     * @param createTimeStartTime
     * @param createTimeEndTime
     * @param isSuccess
     * @param page
     * @param pageSize
     * @return
     */
    public PagerVO<EmailRecordVO> list(Admin admin, String subject, Date createTimeStartTime, Date createTimeEndTime, Boolean isSuccess, int page, int pageSize) {
        Page<EmailRecordVO> emailRecordVOPage = PageHelper.startPage(page, pageSize).doSelectPage(() -> baseMapper.findList(admin.getId(), subject, createTimeStartTime, createTimeEndTime, isSuccess));
        return PagerVO.of(emailRecordVOPage);
    }
}
